<?php

namespace app\common\model\order;
use think\Model;

class ShopOrderLogModel extends Model
{
    // 表名
    protected $name = 'shop_order_log';
    // 表主键
    protected $pk = 'id';
    const STATUS = [
        ['value' => 0, 'label' => '照妖镜检测正常','code' => 'ZYJJC'],
        ['value' => 1, 'label' => '通过接单条件完成派单','code' => 'WCPD'],
        ['value' => 2, 'label' => '完成店铺信息核对','code' => 'DPHD'],
        ['value' => 3, 'label' => '完成订单提交','code' => 'WCDDTJ'],
        ['value' => 4, 'label' => '发货成功','code' => 'FFCG'],
        ['value' => 5, 'label' => '完成评价提交','code' => 'PJTJ'],
        ['value' => 6, 'label' => '评价审核成功','code' => 'PJSHCG'],
        ['value' => 7, 'label' => '评价审核失败','code' => 'PJSHSB'],
        ['value' => 8, 'label' => '评价后24小时自动通过审核','code' => 'PJZDSH'],
        ['value' => 9, 'label' => '已撤销','code' => 'YCX'],
        ['value' => 10, 'label' => '订单完成','code' => 'DDWC'],
        ['value' => 11, 'label' => '完成追评提交','code' => 'WCZPTJ'],
        ['value' => 12, 'label' => '商家发起申诉','code' => 'SJFQSS'],
        ['value' => 13, 'label' => '订单上架','code' => 'DDSJ'],
        ['value' => 14, 'label' => '买家接单','code' => 'MJJD'],
        ['value' => 15, 'label' => '订单回池','code' => 'DDHC'],
        ['value' => 16, 'label' => '订单状态变更','code' => 'DDZTBG'],
        ['value' => 17, 'label' => '订单奖惩','code' => 'DDJC'],
//        ['value' => 12, 'label' => '自动通过审核','code' => 'ZDTGSK'],
//        ['value' => 13, 'label' => '订单审核未通过','code' => 'DDSHWTG'],
//        ['value' => 14, 'label' => '未通过审核','code' => 'WTGSH'],
    ];
    /**
     * 查询状态
     * @Author: 易军辉
     * @DateTime:2024-06-07 16:10
     * @param $key 编码或value
     * @param $type 1、查询value  2、查询名称 3、查询编码
     * @return mixed|void
     */
    public static  function getStatus($key,$type=1)
    {
        foreach (self::STATUS as $status) {
            if ($status['code'] == $key || $status['value'] == $key) {
                switch ($type) {
                    case 1:
                        return $status['value']; // 返回value
                    case 2:
                        return $status['label']; // 返回名称
                    default:
                        return $status['code']; // 未知类型，返回null
                }
            }
        }
    }
}
